/* $Id: AdminNonClientPersonReviewDelegateImpl.java 
 * Copyright (C) 2011, TRAKHEES
 *  
 * Revision History
 *
 * Date  			Author 		    	Remarks
 * ---------------------------------------------------------------------------------
 *
 */
package ae.pcfc.etks.online.common.delegate.provider;


import ae.pcfc.etks.online.common.delegate.AdminNonClientPersonReviewDelegate;
import ae.pcfc.etks.online.common.exception.AdminWorkflowException;
import ae.pcfc.etks.online.common.facade.AdminNonClientPersonReviewFacade;
import ae.pcfc.etks.online.common.vo.AdminApprovalVO;
import ae.pcfc.etks.online.common.vo.NonClientPersonVO;
import ae.pcfc.etks.online.wf.service.client.NonClientWF;
import ae.pcfc.etks.online.wf.service.client.provider.NonClientPersonWFImpl;
import ae.pcfc.etks.online.wf.service.client.vo.NonClientCompleteStepVO;

public class AdminNonClientPersonReviewDelegateImpl  extends BaseDelegateImpl implements AdminNonClientPersonReviewDelegate{
	
	/*
	 * Here we coordinate between the Facade service which handles DB entities
	 * and the WF both will be looked up with service locator normally we will
	 * have 1-1 relationship between the delegate and the facade and 1-1
	 * relationship between the delegate and the WF service which means for
	 * CompanyRegistrationDelegate there will be ClientRegistrationFacade &
	 * CompanyRegistrationWF validations that related to DB vs WF are maintained
	 * here ie user cannot issue a new request while he already have a request
	 * in the wf Exception are translated in to business exception
	 */
	public AdminNonClientPersonReviewDelegateImpl(){
		
	}
	
	/**
	 * getNonClientPersonByApplicationId
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AdminNonClientPersonReviewDelegate#getNonClientPersonByApplicationId(java.lang.String)
	 * 
	 */
	public NonClientPersonVO getNonClientPersonByApplicationId(String applicationId) 
	{
		return serviceLocator.getFacadeService(AdminNonClientPersonReviewFacade.class).getNonClientPersonByApplicationId(applicationId);	 
	}
	
	/**
	 * reviewNonClientPerson
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AdminNonClientPersonReviewDelegate#reviewNonClientPerson(ae.pcfc.etks.online.common.vo.AdminApprovalVO, java.lang.String)
	 * 
	 */
	public void reviewNonClientPerson(AdminApprovalVO adminApprovalVO, String strUserName) 
	{		
		//serviceLocator.getFacadeService(AdminNonClientPersonReviewFacade.class).reviewNonClientPerson(adminApprovalVO, strUserName);
		AdminNonClientPersonReviewFacade adminNonClientPersonReviewFacade = serviceLocator.getFacadeService(AdminNonClientPersonReviewFacade.class);
		NonClientCompleteStepVO completeStepVO = adminNonClientPersonReviewFacade.reviewNonClientPerson(adminApprovalVO, strUserName);
	    try{
			NonClientWF nonClientWF = serviceLocator.getWorkflowService(NonClientPersonWFImpl.class);
			nonClientWF.completeNonClientWFStep(completeStepVO);
	    }catch(Throwable t){
	    	adminNonClientPersonReviewFacade.undoReviewNonClientPerson(adminApprovalVO, completeStepVO.getgTKSID());
	    	throw new AdminWorkflowException(t);
	    }
	}

}
